# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=marked
pkgver=5.0.0
pkgrel=1
pkgdesc="A markdown parser built for speed"
arch=('any')
url='https://github.com/chjj/marked'
license=('MIT')
depends=('nodejs')
makedepends=('npm')
source=(https://registry.npmjs.org/$pkgname/-/$pkgname-$pkgver.tgz)
noextract=($pkgname-$pkgver.tgz)
sha512sums=('610ebe2fd97f3520438c580241079b99309ceb6114759e51a4867b03f1660bc218301e6cec2cfcb13ee29ae30091b20be02bd7a502dd5b8e5fa4ae54c2253b0c')

package() {
  npm install -g --prefix "$pkgdir"/usr "$srcdir"/$pkgname-$pkgver.tgz

  # Non-deterministic race in npm gives 777 permissions to random directories.
  # See https://github.com/npm/npm/issues/9359 for details.
  chmod -R u=rwX,go=rX "$pkgdir"

  # npm installs package.json owned by build user
  # https://bugs.archlinux.org/task/63396
  chown -R root:root "$pkgdir"

  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s ../../../lib/node_modules/marked/LICENSE.md "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.md
}
